<style >
  table.formTable {
    font-family: verdana, arial, sans-serif;
    font-size: 0.875rem;
    color: #333333;
    border-width: 0px;
    border-color: #dcdfe6;
    border-collapse: collapse;
    width: 100%;
  }

  table.formTable td {
    border-width: 0px;
    padding: 20px;
    border-style: solid;
    border-color: #dcdfe6;
    background-color: #ffffff;
    padding:2px;
    text-align: center;
  }

  table.formTable td:first-child {
    width: 100px;
    text-align: right;
  }

  table.formTable td:last-child {
  	 color: #E6A23C; 
  }
  
      #tableIconForBizWsLog + .layui-table-view .layui-table-body tbody > tr > td {
        padding: 0;
    }

    #tableIconForBizWsLog + .layui-table-view .layui-table-body tbody > tr > td > .layui-table-cell {
        height: 60px;
        line-height: 60px;
    }

    .tdImg {
        width: 35px;
        height:35px;
        max-width: none;
        cursor: pointer;
    }

    .layui-table-view {
        margin: 0;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar" id="tbToolBar">
                <div class="layui-form-item">
                    <div class="layui-inline" style="float: right;margin-right: 0px;">
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<label class="layui-form-label w-auto">名称</label>
							<div class="layui-input-inline mr0">
								<input name="name" class="layui-input" type="text" placeholder="请输入名称"/>
							</div>
						</div>
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<button class="layui-btn icon-btn" lay-filter="formSubSearchBizWsLog" lay-submit>
								<i class="layui-icon">&#xe615;</i>查询
							</button>
						</div>					
					</div>
				</div>
				<table class="layui-table" id="tableBizWsLog" lay-filter="tableBizWsLog"></table>
			</div>
		</div>
	</div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBarBizWsLog">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 表格状态列 -->
<script type="text/html" id="tableStateBizWsLog">
#[[  {{#  if(d.status === '1'){ }}
    <span style="color: #23aa2e;">正常</span>
  {{#  } else { }}
	<span style="color: #ff0000;">禁止</span>
  {{#  } }}
]]#
</script>


<!-- 表单弹窗-->
 <script type="text/html" id="modelBizWsLog">
    <form id="modelBizWsLogForm" lay-filter="modelBizWsLogForm" class="layui-form model-form" style="padding: 5px;">
        <input name="id" type="hidden"  />
		<table class="formTable">
			<tr>
				<td>推送端</td>
				<td colspan="3" style="text-align: left;">
                	<input name="senderId"  placeholder="" readonly="readonly" type="text" class="layui-input" lay-verType="tips" lay-verify="required" required/>
                </td>
			</tr>
			<tr>
				<td>接收端</td>
				<td colspan="3" style="text-align: left;">
                	<input name="receiverId"  placeholder="" readonly="readonly" type="text" class="layui-input" />
                </td>
			</tr>
			<tr>
				<td>标识</td>
				<td colspan="3" style="text-align: left;">
                	<input name="code"  placeholder="请输入标识" readonly="readonly" type="text" class="layui-input" />
                </td>
			</tr>
			<tr>
				<td>内容</td>
				<td colspan="3" style="text-align: left;">
               	 	<textarea name="content" placeholder="请输入内容" class="layui-textarea" maxlength="200"></textarea>
                </td>
			</tr>
		</table>    
    </form>
</script>


<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin', 'config','colorpicker'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var config = layui.config;
        var colorpicker = layui.colorpicker;
        // 渲染表格
        var insTb = table.render({
            elem: '#tableBizWsLog',
            url: '#(ctx)/biz/ws/log/listData', 
            page: true,
            toolbar: false,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: '序号'},
                {field: 'senderId', sort: false, title: '推送端'},
                {field: 'receiverId', sort: false, title: '接收端'},
                {field: 'code', sort: false, title: '标识'},
                {field: 'scope', sort: false, title: '范围'},
                {field: 'content', sort: false, title: '内容'},
                {
                    field: 'createTime', sort: false, templet: function (d) {
                        return util.toDateString(d.createTime);
                    }, title: '时间'
                },
                {align: 'left', toolbar: '#tableBarBizWsLog', title: '操作'}
            ]],
        });


        // 搜索
        form.on('submit(formSubSearchBizWsLog)', function (data) {
            insTb.reload({where: data.field}, 'data');
        });

        // 工具条点击事件
        table.on('tool(tableBizWsLog)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'edit') { 
            	showEditModel(data);
            } else if (layEvent === 'del') { 
                doDel(data.id, data.code);
            }
        });

        // 删除
        function doDel(id, name) {
            layer.confirm('确定要删除“【<span style="color:red;">' + name + '</span>】”吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('biz/ws/log/delete', {
                    id: id
                }, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.message, {icon: 1});
                        insTb.reload({}, 'data');
                    } else {
                        layer.msg(res.message, {icon: 2});
                    }
                }, 'get');
            });
        }
        // 显示表单弹窗
        function showEditModel(data) {
            layer.open({
                type: 1,
                shade: 0.3,
                offset: 't'	,
                title: '查看',
                area:'500px',
                resize :false,
                content: $('#modelBizWsLog').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    form.val('modelBizWsLogForm', data);  // 回显数据
    			    form.render(); 
                },
                end:function(){
                }
            });
        }

    });
    
    
</script>
